package com.yanqu.road.server.cmd.activity.jinli.cross;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.JinLiProto;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.Command;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.server.protocol.Protocol;
import io.netty.channel.ChannelHandlerContext;

@Cmd(code = Protocol.S_JINLI_SYNC_DATA_FROM_CROSS, desc = "跨服发来锦鲤信息同步")
public class JinLiSyncDataFromCross implements Command {

    @Override
    public void execute(ChannelHandlerContext ctx, YanQuMessage packet) throws Exception {
        JinLiProto.JinLiDataSyncMsg respMsg = JinLiProto.JinLiDataSyncMsg.parseFrom(packet.getBytes());
        // 广播给所有在线用户
        for (GamePlayer gamePlayer : GamePlayerMgr.getAllOnlinePlayer()) {
            gamePlayer.sendPacket(Protocol.U_JINLI_DATA_SYNC, respMsg.toBuilder());
        }
    }
}
